package com.tyj.movie.service.impl;

import com.tyj.movie.constant.RedisConstant;
import com.tyj.movie.entity.MovieTheatreShow;
import com.tyj.movie.mapper.MovieTheatreShowMapper;
import com.tyj.movie.service.MovieTheatreShowService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tyj
 * @since 2021-06-28
 */
@Service
public class MovieTheatreShowServiceImpl extends ServiceImpl<MovieTheatreShowMapper, MovieTheatreShow> implements MovieTheatreShowService {


    @Autowired
    RedisTemplate<String,String> redisTemplate;

    @Override
    public List<String> queryBuySeat(Long movieShowId) {
        Set<String> members = redisTemplate.opsForSet().members(RedisConstant.MOVIE_THEATRE_SEAT + movieShowId);
        List<String> list =new ArrayList<>(members);
        return list;
    }

    @Override
    public MovieTheatreShow getMovieTheatreNameAndBrandById(Long movieShowId) {
        MovieTheatreShow movieTheatreShow = this.baseMapper.getMovieTheatreNameAndBrandById(movieShowId);
        return movieTheatreShow;
    }
}
